package com.lanou3g.mynewstest.module.videos;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;

import com.lanou3g.mynewstest.R;
import com.lanou3g.mynewstest.base.MyBaseActivity;
import com.lanou3g.mynewstest.tools.MediaController;
import com.lanou3g.mynewstest.tools.MyVideoView;

/**
 * Created by dllo on 16/1/15.
 */
public class VideoActivity extends MyBaseActivity implements MyVideoView.PlayPauseListener {
    private MyVideoView mVideoView;
    private MediaController mMediaController;
    private static Context context;
    private ImageView   start,stop;
    private static String url;
    public static void goToVideoActivity(Context context,String url){
        VideoActivity.context=context;
        VideoActivity.url=url;
        Intent intent=new Intent(context,VideoActivity.class);
        context.startActivity(intent);
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_video);
        mVideoView = (MyVideoView) findViewById(R.id.video_view);
        mVideoView.setPlayPauseListener(this);
        start= (ImageView) findViewById(R.id.video_start);
        stop= (ImageView) findViewById(R.id.video_stop);
        stop.setVisibility(View.INVISIBLE);
        mVideoView.setVideoURI(Uri.parse(url));
        mMediaController = new MediaController(this);
        mVideoView.setMediaController(mMediaController);
        mVideoView.setFocusableInTouchMode(false);
        mVideoView.setFocusable(false);
        mVideoView.setEnabled(false);
    }
    @Override
    public void start() {
        start.setVisibility(View.INVISIBLE);
        stop.setVisibility(View.INVISIBLE);
        Log.d("VideoActivity", "start");
    }

    @Override
    public void stop() {
        stop.setVisibility(View.VISIBLE);
    }
}
